<!DOCTYPE html>
<html lang="en">
<head>
    <title>考勤签到</title>
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="Cache-Control" content="no-store, must-revalidate">
    <meta http-equiv="expires" content="Wed, 26 Feb 1997 08:21:57 GMT">
    <meta http-equiv="expires" content="-1">
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"
          name="viewport">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="shortcut icon" href="/dist/img/icon.png" type="image/x-icon">
    <!--字体-->
    <link rel="stylesheet" href="/dist/css/font-awesome.min.css">
    <script src="https://file.ggxqce.com/web/vue.min.js"></script>
    <link rel="stylesheet" href="/dist/plugins/calendar/calendar.css" />
</head>
<style>
    [v-cloak] {
        display: none;
    }

    * {
        -webkit-box-sizing: border-box;
        -moz-box-sizing: border-box;
        box-sizing: border-box;
        font-size: 12px;
    }

    body {
        margin: 1px;
        background: #ffffff;
    }

    table {
        border-spacing: 0;
        border-collapse: collapse;
        display: table;
    }

    .weather {
        text-align: center;
        font-size: 16px;
        position: absolute;
        top: 5px;
        line-height: 24px;
        float: left;
    }

    th {
        font-weight: bold;
    }

    table.text-center, table.text-center td, table.text-center th {
        text-align: center;
        font-size: 12px;
    }

    .table-bordered > thead > tr > th, .table-bordered > tbody > tr > th, .table-bordered > tfoot > tr > th, .table-bordered > thead > tr > td, .table-bordered > tbody > tr > td, .table-bordered > tfoot > tr > td {
        border: 1px solid #cbcbcd;
        height: 24px;
        position: relative;
        color: #333;
        padding: 0 4px;
    }

    table th {
        background: #f8f8f8;
    }

    .table-bordered {
        border: 1px solid #cbcbcd;
    }

    .table {
        width: 100%;
        max-width: 100%;
    }

    .hidden {
        display: none;
    }

    .lineOne, .lineTwo {
        text-align: left;
    }

    .tdColor {
        background-color: #f8f8f8;
        font-weight: bold;
    }

    .lineOne span {
        max-height: 24px;
        line-height: 24px;
        overflow: hidden;
        text-overflow: ellipsis;
        display: -webkit-box;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 1;
        text-align: left;
    }

    .lineTwo span {
        max-height: 48px;
        line-height: 14px;
        overflow: hidden;
        text-overflow: ellipsis;
        display: -webkit-box;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 3;
        text-align: left;

    }

    .div-td-content-more {
        position: absolute;
        height: auto;
        z-index: 999;
        line-height: 20px;
        background-color: #d3e8fd;
        padding: 8px 6px;
        border: 1px solid #e8e8ea;
        display: none;
    }

    .div-td-content-more i {
        width: 15px;
        height: 12px;
        background: url("/dist/img/more-icon.png");
        position: absolute;
        left: 50px;
        top: -12px;
    }

    .clear {
        clear: both
    }

    .boxItem {
        width: 100%;
        padding: 10px;
        padding-top: 5px;
        padding-bottom: 0;
        background: inherit;
        background-color: rgba(255, 255, 255, 1);
        border: none;
        position: relative;
    }

    .boxItemTitle {
        color: #000;
        font-size: 16px;
        font-weight: bold;
        margin-bottom: 6px;
        text-align: right;
    }

    .home {
        font-size: 14px;
        font-weight: bold;
        margin-bottom: 10px;
        height: 14px;
        line-height: 14px;
        text-align: center;
    }

    .dian-icon {
        background: url("/dist/img/dian.png") no-repeat;
        background-size: cover;
        width: 14px;
        height: 14px;
        display: inline-block;
    }

    .jiaobiao, .jiaobiaoNew {
        position: relative;
    }

    .jiaobiao i {
        display: block;
        width: 0;
        height: 0;
        border-width: 0px 0 12px 12px;
        border-style: solid;
        border-color: transparent transparent transparent #2a8cec;
        position: absolute;
        top: 0px;
        left: 0px;
    }

    .jiaobiaoNew i {
        display: block;
        width: 12px;
        height: 12px;
        background: url("/dist/img/newLog2.png");
        background-size: 100% 100%;
        position: absolute;
        top: 0px;
        left: 0px;
    }

    .lineImg {
        padding-top: 5px !important;
        padding-bottom: 10px !important;
    }

    .lineImg img {
        height: 45px;
        width: 45px;
        float: left;
        margin: 10px;
    }

    .newCustomer {
        background: url(/dist/img/new.png) no-repeat;
        background-size: cover;
        width: 20px;
        height: 20px;
        right: 0;
        top: 2px;
        position: absolute;
    }

    .wajueji {
        padding-left: 140px;
        background: url("/dist/img/wajueji.png") no-repeat;
        background-size: 120px 88px;
        height: 88px;
        line-height: 88px;
        color: red;
        font-size: 14px;
        font-weight: bold;
        margin-left: 50px;
    }

    .qipao {
        /*background: url(/dist/img/qipao.png);*/
        background-size: 100% 100%;
        height: 88px;
        /* padding: 0 20px; */
        padding-left: 20px;
        /*padding-right: 20px;*/
        color: red;
        line-height: 88px;
        float: left;
        font-size: 14px;
        font-weight: bold;
    }

    .plan1 {
        background: url("/dist/img/plan1.png") no-repeat center center;
        background-size: 100%;
    }

    .plan2 {
        background: url("/dist/img/plan2.png") no-repeat center center;
        background-size: 100%;
    }

    .plan3 {
        background: url("/dist/img/plan3.png") no-repeat center center;
        background-size: 100%;
    }

    .boxItemTitleNotice {
        color: red;
        font-size: 22px;
        font-weight: bold;
        margin-bottom: 10px;
        text-align: center;
    }

    .boxItemTitleNotice i {
        background: url("/dist/img/jg.png") no-repeat center center;
        height: 22px;
        width: 22px;
        background-size: cover;
        display: inline-block;
        margin-bottom: -3px;
        margin-left: 5px;
    }

    .boxItemTitleNoticeTime {
        color: red;
        font-size: 20px;
        font-weight: bold;
        margin-bottom: 10px;
        text-align: center;
    }

    .boxItemTitleNoticeTime i {
        background: url("/dist/img/jg.png") no-repeat center center;
        height: 16px;
        width: 16px;
        background-size: cover;
        display: inline-block;
        margin-bottom: -3px;
        margin-left: 5px;
    }

    .search-button {
        width: 14px;
        height: 14px;
        background-image: url(/dist/img/glass.jpg);
        border: 0 none;
        cursor: pointer;
        margin-top: 0px;
    }

    input[type=button] {
        outline: none;
    }

    .oaBtn {
        background: url(/dist/img/btn-bj2.png) repeat-y !important;
        background-size: 100% 100% !important;
        color: #fff !important;
    }

    .btn-group-sm > .btn, .btn-sm {
        padding: 2px 10px;
    }

    .btn {
        border-radius: 3px;
        -webkit-box-shadow: none;
        box-shadow: none;
        border: 1px solid transparent;
    }

    .pull-right {
        float: right !important;
    }

    .blue {
        color: #39c;
    }

    .red {
        color: #e03800;
    }

    .weather img {
        height: 26px;
        width: 26px;
        float: left;
    }

    .info p {
        margin: auto;
    }

    .templateStyle {
        margin-top: 15px;
        margin-left: 10px;
        margin-right: 10px;
        box-shadow: 2px 2px 3px #DDDDDD;
    }

    .qingjia {
        background: url("/dist/img/icon_seal_qingjia.png") no-repeat bottom right;
        background-size: 30%;
    }
    .ht-rili-leftarr,.ht-rili-rightarr{
        display: none;
    }
    .tryStyle {
        width: 34px;
        height: 17px;
        line-height: 17px;
        font-size: 12px;
        top: -3px;
        right: -29px;
        position: absolute;
        border-radius: 50px;
        margin-top: 4px;
        background: #ff131c;
        color: #fff;
        margin-right: -2px;
        transform: scale(0.7);
        text-align: center;
    }
</style>
<body>
<section class="content" id="app" v-cloak>
    <div class="div-td-content-more"><i></i></div>
    <!--考勤签到-->
    <div class="templateStyle" v-for="(item,i) in signIn">
        <!--天气-->
        <div style="position:relative;height: 28px;border: 1px solid #cbcbcd;background-color: #fff">
            <div class="weather" v-if="item.result.weather"
                 style="position:absolute;top: 0px;left:0px;">
                <b style="margin: 0 2px;">{{item.result.weather.text_day}}</b><font
                    class="blue">{{item.result.weather.low}}</font>～<font
                    class="red">{{item.result.weather.high}}</font>℃<img
                    :src="'/dist/img/weather/'+item.result.weather.code_day+'.png'"/>
            </div>
            <div style="display:block;text-align: center;line-height: 26px">考勤签到</div>
            <div style="position:absolute;top: 0;right:0;bottom: 0;font-size: 12px;background: #2a8cec;color: #fff;padding: 3px 6px">
                <span v-if="item.result.userId==getUrlParamObj().userId"
                      @click="lookInfo(getUrlParamObj().userId)">基本信息</span>
                <span v-else @click="lookInfo(item.result.userId)">{{item.result.userName.length<3?item.result.userName.substring(0,1)+'&nbsp;&nbsp;&nbsp;&nbsp;'+item.result.userName.substring(1,2):item.result.userName}}</span>
            </div>
        </div>
        <template v-if="item.signState==='0'">
            <!--请假-->
            <!--<div style="background: #ffffff;padding-left: 16px;padding-top: 16px;font-size: 16px;border: 1px solid #cbcbcd;margin-top: -1px;border-bottom: 0px;">-->
            <!--日期：{{get_date(item.result.beginTime,item.result.endTime)}}-->
            <!--</div>-->
            <div class="calendar-box demo-box" :id="'demo-box'+i" v-calendar-inserted="i"></div>
            <div style="padding:5px 10px;    border: 1px solid rgb(203, 203, 205);">
                <div style="display: flex">
                    <span > 请假原因：</span>
                    <span style="flex: 1" class="qjyy">{{item.result.remark}}</span>
                </div>

            </div>

        </template>
        <template v-else-if="item.signState==2">
            <!--缺勤-->
            <div style="text-align: center;background: #ffffff;padding: 30px;border: 1px solid #cbcbcd;border-top: 0px;">
                <div style="text-align: center"><img width="45%"
                                                     src="/dist/img/icon_seal_queqin.png">
                </div>
            </div>
        </template>
        <template v-else>
            <!--正常签到-->
            <img v-if="item.result.signUrl" :src="item.result.signUrl"
                 alt=""
                 style="width: 100%; height: 400px;display: block;border: 1px solid #cbcbcd;margin-top: -1px;object-fit: fill;">
            <div v-if="item.result.signUrl"
                 style="padding:5px 10px;border:  1px solid #cbcbcd;margin-top: -1px;">
                <div style="display: flex">
                    <span >常驻地：</span>
                    <span style="flex: 1">{{(item.result.residence).replace(/(^\s+)|(\s+$)/g,"")}}</span>
                </div>
                <span style="margin-top: 2px">签到地：{{(item.result.address).replace(/(^\s+)|(\s+$)/g,"")}}</span><br/>
                <span style="margin-top: 2px;">相&nbsp;&nbsp;&nbsp;&nbsp;距：{{item.result.signInAlwaysDistance}}</span>
                <span style="float: right;position: relative;right: 20px;" v-if="isLate(item.result.signCreateTime)">
                    签到时间：{{item.result.signCreateTime}}
                    <template v-if="isLate(item.result.signCreateTime)">
                        <span class="tryStyle">迟到</span>
                    </template>
                </span>
                <span style="float: right;position: relative;" v-else>
                    签到时间：{{item.result.signCreateTime}}
                </span>
            </div>
            <!--<img v-if="item.result.signOutUrl" :src="item.result.signOutUrl"-->
            <!--alt="" style="width: 100%; height: 100%;display: block;border: 1px solid #cbcbcd;">-->
        </template>
        <div style="margin-bottom: 15px;"></div>
    </div>
</section>
<!--JQ-->
<script src="https://file.ggxqce.com/web/jquery-2.2.3.min.js"></script>
<!--插件JS-->
<script src="/dist/plugins/scroll/myScroll.js"></script>
<!--框架已定义 JS-->
<!--oa自定义  JS-->
<script src="/dist/js/oaApp.js"></script>

<script type="text/javascript" src="/dist/plugins/lhgdialog/lhgdialog.min.js?self=true"></script>
<script src="/dist/plugins/calendar/calendar-pro.js"></script>
<script>
    $(function () {
        $("body").on("click", ".lineOne,.lineTwo", function (e) {
            if ($(".div-td-content-more").is(":hidden")) {
                var text = $(this).text();
                if (text != "") {
                    text = "<i></i>" + text;
                    $(".div-td-content-more").html(text).css({
                        "width": $(this).outerWidth() + "px",
                        "left": $(this).offset().left,
                        "top": ($(this).offset().top + $(this).outerHeight()) + "px"
                    }).show();
                    e.stopPropagation();
                }
            } else {
                $(".div-td-content-more").hide();
            }
        });
        $("body").on("click", ".div-td-content-more", function (e) {
            e.stopPropagation();
        });
        $("body").on("click", function () {
            $(".div-td-content-more").hide();
        });
    });
</script>
<script>
    $.ajaxSetup({
        global: true,
        type: "POST",
        cache: false,
        dataType: "json",
        contentType: 'application/json;charset=utf-8',
        beforeSend: function () {
        },
        complete: function () {

        },
        error: function (e) {
            alert('error' + e.responseText);
        }
    });
    $.extend($.wyui, {
        postMethod: function (url, data, callback, sync, id) {
            if (!id) {
                id = "#app"
            }
            $.ajax({
                url: server.ip + url,
                async: sync ? false : true,
                data: JSON.stringify(data),
                beforeSend: function () {

                },
                complete: function () {
                    setTimeout(function () {
                    }, 1000);

                },
                success: function (r) {
                    if (!r.e.code) {
                        callback(r.data.sendData);
                    } else {
                        alert(r.e.desc);
                    }
                },
                error: function (e) {
                    alert(url + e.responseText);
                }
            });
        },
    });
</script>
<script type="text/javascript">
    var app = new Vue({
        el: "#app",
        data: {
            userId: getUrlParamObj().userId,
            dateTime: getUrlParamObj().dateTime,
            regionId: getUrlParamObj().departId ? getUrlParamObj().departId : '',
            weather: {},
            signIn: [],
            signState: ''
        },
        methods: {
            //一线是否迟到
            isLate: function (dateStr) {
                var date = new Date('2018-01-01 '+dateStr)
                if (date.getHours() == 8 && date.getMinutes() > 0) {
                    return true
                } else if (date.getHours() > 8) {
                    return true
                } else {
                    return false
                }
            },
            //打开基本信息
            lookInfo: function (userId) {
                var that = this
                var obj = {
                    type: 'customerList',
                    url: '/reportForm/personnel/entry.html?userId=' + userId,
                    name: '基本信息'
                }
                prompt(JSON.stringify(obj));
            },
            //获取天气
            get_weather: function (item, i, lat, lng) {
                var that = this;
                $.wyui.postMethod(urlConfig.other.getTheWeather, {
                    "lat": lat,
                    "lng": lng
                }, function (data) {
                    var weather = data.weather[0];
                    var obj = {
                        'text_day': weather.text_day,
                        'low': weather.low,
                        'high': weather.high,
                        'code_day': weather.code_day
                    }
                    that.signIn[i].result.weather = obj
                    console.log(that.signIn[i].result)
                }, true);
            },
            get_date: function (list) {
                var data;
                var current = [];
                var last = [];
                var next = [];
                var benNian = new Date().Format("yyyy");
                var benYue = new Date().Format("M");
                var lastTime = '';
                var currentTime = new Date().Format("yyyy-MM");
                var today = new Date().Format("yyyy-MM-dd");
                var nextTime = '';
                if (Number(benYue) + 1 > 12) {
                    nextTime = Number(benNian) + 1 + "-01"
                } else if (Number(benYue) + 1 < 10) {
                    nextTime = Number(benNian) + "-0" + (Number(benYue) + 1)
                } else {
                    nextTime = Number(benNian) + "-" + (Number(benYue) + 1)
                }
                if (Number(benYue) - 1 < 1) {
                    lastTime = Number(benNian) - 1 + "-12"
                } else if (Number(benYue) - 1 < 10) {
                    lastTime = Number(benNian) + "-0" + (Number(benYue) - 1)
                } else {
                    lastTime = Number(benNian) + "-" + (Number(benYue) - 1)
                }
                for(var i=0;i<list.length;i++){
                    if (lastTime == list[i].leaveDate.substring(0, 7)) {
                        last.push({date: list[i].leaveDate, data: '假',yy:list[i].remark})
                    }
                    if (currentTime == list[i].leaveDate.substring(0, 7)) {
                        if(today == list[i].leaveDate){
                            current.push({date:list[i].leaveDate, data: '假',today:true,yy:list[i].remark})
                        }else{
                            current.push({date:list[i].leaveDate, data: '假',yy:list[i].remark})
                        }
                    }
                    if (nextTime == list[i].leaveDate.substring(0, 7)) {
                        next.push({date: list[i].leaveDate, data: '假',yy:list[i].remark})
                    }
                }
                data = {
                    last: last,
                    current: current,
                    next: next
                }
                console.log(data)
                return data

            },
            getCountDays: function (dateStr) {//返回当月的天数
                var curDate = new Date(dateStr);
                var curMonth = curDate.getMonth();
                curDate.setMonth(curMonth + 1);
                curDate.setDate(0);
                return curDate.getDate();
            },
            //获取考勤签到
            get_signIn: function () {
                var that = this;
                if (isWeiXin()) {

                } else {
                    var dialog = {
                        dialog: 'show'
                    }
                    prompt(JSON.stringify(dialog))
                }
                $.wyui.postMethod(urlConfig.newDaQuReportForm.getTodaySignForBRM, {
                    "userId": that.userId,
                    "dateTime": that.dateTime,
                    "regionId": that.regionId,
                }, function (data) {
                    that.signIn = data.records.filter(function (element, i, self) {
                        return  (self[i].signState == 1 && that.isLate(self[i].result.signCreateTime)) || self[i].signState ==2;
                    })
                    for (var i = 0; i <that.signIn.length; i++) {
                        if (that.signIn[i].result.latitude) {
                            that.get_weather(that.signIn[i], i, that.signIn[i].result.latitude, that.signIn[i].result.longitude)
                        }
                    }
                    if (isWeiXin()) {

                    } else {
                        var dialog = {
                            dialog: 'hidden'
                        }
                        prompt(JSON.stringify(dialog))
                    }
                });
            },
            setMessageReadFlag: function (receiverId) {
                $.wyui.postMethod(urlConfig.system.message.setMessageReadFlag, {
                    receiverId: receiverId,
                    flag: '1'
                }, function (data) {
                })
            }
        },
        mounted: function () {
            var that = this;
            that.get_signIn();
            if (getUrlParamObj().msg == "0") {
                //从消息点进来的,标为已读
                this.setMessageReadFlag(getUrlParamObj().receiverId)
            }
        }
    })
</script>
<script>
    Vue.directive('calendar-inserted', {
        inserted: function (el, binding) {
            var lineIndex = binding.value;
            showCalendar(lineIndex);
        }
    });
    function showCalendar(lineIndex) {
        $.wyui.postMethod("/newAppReportForZSQ/getCalendar.json", {
            "userId": app.signIn[lineIndex].result.userId,
            "dateTime": new Date().Format("yyyy-MM"),
        }, function (data) {
            var res = app.get_date(data)
            $('#demo-box' + lineIndex).calendar({
                ele: '#demo-box' + lineIndex, //依附
                title: '',
                data: res
            });
        });
    }
</script>
</body>
</html>